package com.education.ai.repository;

import com.education.ai.entity.TeachingPlan;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * 教学计划资源库接口
 */
@Repository
public interface TeachingPlanRepository extends JpaRepository<TeachingPlan, Long>, JpaSpecificationExecutor<TeachingPlan> {
    
    /**
     * 根据学科查找教学计划
     */
    List<TeachingPlan> findBySubject(String subject);
    
    /**
     * 根据年级查找教学计划
     */
    List<TeachingPlan> findByGrade(String grade);
    
    /**
     * 根据学科和年级查找教学计划
     */
    List<TeachingPlan> findBySubjectAndGrade(String subject, String grade);
    
    /**
     * 根据标题模糊查询
     */
    List<TeachingPlan> findByTitleContaining(String title);
    
    /**
     * 根据标题模糊查询，学科和年级精确查询
     */
    List<TeachingPlan> findByTitleContainingAndSubjectAndGrade(String title, String subject, String grade);
    
    /**
     * 查找模板教学计划
     */
    List<TeachingPlan> findByIsTemplateTrue();
    
    /**
     * 根据教师ID查询教学计划
     */
    List<TeachingPlan> findByTeacherId(String teacherId);
    
    /**
     * 根据教师ID查询教学计划并按创建时间降序排序
     */
    List<TeachingPlan> findByTeacherIdOrderByCreateTimeDesc(String teacherId);
} 